<%-- 
    Document   : nicks
    Created on : 19-oct-2008, 17:28:29
    Author     : org.@le

--%>

<%@taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@taglib uri="http://richfaces.org/rich" prefix="rich"%>

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <c:if test="${sessionBean.ejbSession.owner==null}" >
            <jsp:forward page="../login.jsp" />
        </c:if>
        <c:if test="${!sessionBean.ejbSession.owner.adminUser}" >
            <jsp:forward page="../user/homeUser.jsp" />
        </c:if>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        
        <f:view>
            <a4j:region>
            <h:form id="flagPosts">
            <a4j:commandButton style="width: 100px; right:10px; top:10px; position:absolute;" value="Clean postings" action="#{postBean.checkingPostings}" reRender="formPosts" />
            <h:panelGrid width="100%">
                <rich:toolBar style="position:absolute; top: 10px; left: 10px" width="300px">
                    <a href="/site-es/faces/admin/admin.jsp" >Admin panel</a> > 
                    <h:outputText value="Flagged Postings" />
                </rich:toolBar>
            </h:panelGrid>
            <br/>
            <h2>Flagged Postings</h2>
            <h:panelGrid columns="3">
              <h:selectOneMenu value="#{FlagedPostsBean.searchType}" >
                    <f:selectItem itemLabel="job" itemValue="job" />
                    <f:selectItem itemLabel="house" itemValue="house" />
                    <f:selectItem itemLabel="resume" itemValue="resume" />
                    <f:selectItem itemLabel="gig" itemValue="gig" />
                    <f:selectItem itemLabel="service" itemValue="service" />
                    <f:selectItem itemLabel="sale" itemValue="sale" />
                    <f:selectItem itemLabel="personal" itemValue="personal" />
                    <f:selectItem itemLabel="event" itemValue="event" />
                    <f:selectItem itemLabel="community" itemValue="community" />
                </h:selectOneMenu>
                <h:selectOneMenu value="#{FlagedPostsBean.flagType}" >
                    <f:selectItem itemLabel="miscategorized" itemValue="miscategorized" />
                    <f:selectItem itemLabel="prohibited" itemValue="prohibited" />
                    <f:selectItem itemLabel="spam" itemValue="spam" />
                    <f:selectItem itemLabel="best" itemValue="best" />
                </h:selectOneMenu>
                <a4j:commandButton value="Go!" reRender="formPosts"/>
                <a4j:status>
                        <f:facet name="start">
                            <h:graphicImage  value="/images/ajax_process.gif"/>
                        </f:facet>
                    </a4j:status>
                    </h:panelGrid>
            </h:form>
                <br/>
            <h:form id="formPosts">
                <h:messages globalOnly="true" />
                <h:outputText value="No postings were found." rendered="#{empty FlagedPostsBean.postsFound}"/>
                <c:if test="${!empty FlagedPostsBean.postsFound}">
                <rich:dataTable style="font-size:15px;" id="postingsUserTable" rows="100" value="#{FlagedPostsBean.postsFound}" var="post" border="1" >
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="Code" />
                        </f:facet>
                        <h:outputText value="#{post.code}" />
                    </rich:column>
                    
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="Fecha de publicación" />
                        </f:facet>
                        <h:outputText value="#{post.publishDate}" rendered="#{post.status=='active'}" >
                            <f:convertDateTime type="date" dateStyle="medium"/>
                        </h:outputText>
                        <h:outputText value=" - " rendered="#{post.status=='pending'}" />
                    </rich:column>
                    
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="Site" />
                        </f:facet>
                        <h:outputText value="#{post.site.site}" />
                    </rich:column>
                    
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="Categoría" />
                        </f:facet>
                        <h:outputText value="#{post.categorie}" />
                    </rich:column>
                    
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="Título" />
                        </f:facet>
                        <h:outputText value="#{post.title}" />
                    </rich:column>
                    
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="Fee" />
                        </f:facet>
                        <h:outputText value="#{post.fee}" />
                    </rich:column>
                    
                    <rich:column rendered="#{FlagedPostsBean.flagType=='miscategorized'}">
                        <f:facet name="header">
                            <h:outputText value="Miscategorized" />
                        </f:facet>
                        <h:outputText value="#{post.miscategorized}" />
                    </rich:column>
                    
                    <rich:column rendered="#{FlagedPostsBean.flagType=='prohibited'}">
                        <f:facet name="header">
                            <h:outputText value="Prohibited" />
                        </f:facet>
                        <h:outputText value="#{post.prohibited}" />
                    </rich:column>
                    
                    <rich:column rendered="#{FlagedPostsBean.flagType=='spam'}">
                        <f:facet name="header">
                            <h:outputText value="Spam" />
                        </f:facet>
                        <h:outputText value="#{post.spam}" />
                    </rich:column>
                    
                    <rich:column rendered="#{FlagedPostsBean.flagType=='best'}">
                        <f:facet name="header">
                            <h:outputText value="Best" />
                        </f:facet>
                        <h:outputText value="#{post.best}" />
                    </rich:column>
                    
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="Options" />
                        </f:facet>
                        <a4j:commandButton value="Delete" action="#{FlagedPostsBean.delete}" onclick="if(!confirm('The Post will be deleted. Are you sure?'))return false" reRender="formPosts">
                            <f:setPropertyActionListener target="#{FlagedPostsBean.post}" value="#{post}"/>
                        </a4j:commandButton>
                    </rich:column>
                    
                </rich:dataTable>
                <rich:spacer height="10" />
                <rich:datascroller id="scr" for="postingsUserTable" maxPages="10" page="#{FlagedPostsBean.pagePostings}" />
                </c:if>
            </h:form>
            </a4j:region>
        </f:view>
    </body>
</html>
